package SwingView.Assignment;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import JDBC.InstructorAssignmentActivities;
import JDBC.StudentAssignmentActivities;
import SwingModel.CmsAssignment;
import SwingModel.CmsInstructor;
import SwingModel.CmsUser;
import SwingView.CmsMainView;
import SwingView.CmsPageSelector.CmsPage;

public class ALAssignment implements ActionListener{
	
	private CmsMainView mainView;
	private CmsUser user;

	//---------------------------------------------------------
	//CONSTRUCTOR:
	//---------------------------------------------------------		
	public ALAssignment(CmsMainView mainView, CmsUser user){
		this.mainView = mainView;
		this.user = user;
	}

	//---------------------------------------------------------
	//PERFORMING ACTION:
	//---------------------------------------------------------		
	@Override
	public void actionPerformed(ActionEvent e){
		
		List<CmsAssignment> listOfAssignment = new ArrayList();
		
		
		if (user instanceof CmsInstructor){//Instructor case
			listOfAssignment = InstructorAssignmentActivities.getListOfAssignments(user.getSelectedCourse().getCourseID());
			//Highlight the Assignment Button
			mainView.displayAssignmentInstructorPage(listOfAssignment);
		}
		else{//Student case
			
			
			int asgmID = 0;
			String asgmTitle = "Assignment 1";
			String asgmDescription = "Date and time formats are specified by date and time pattern strings. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing."
										+ "\n\nThe following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved";
			List<File> asgmFile = new ArrayList(); 
			asgmFile.add(new File("./AsgmFiles/cd"));
			asgmFile.add(new File("./AsgmFiles/cms613.mwb.bak"));
			asgmFile.add(new File("./AsgmFiles/test.sql"));
			double percentWeight = 19.0d;
			Date createdDate = new Date();
			Date avaiDate = new Date(1386081900000l);
			Date dueDate = new Date(1386692100000l);
			Date expDate = new Date(1387708980000l);
			listOfAssignment.add(new CmsAssignment(asgmID, asgmTitle, asgmDescription, asgmFile, percentWeight, createdDate, avaiDate, dueDate, expDate));
			
			int asgmID2 = 0;
			String asgmTitle2 = "Assignment 2";
			String asgmDescription2 = "Description 2";
			List<File> asgmFile2 = new ArrayList(); 
			asgmFile2.add(new File("./AsgmFiles/cd"));
			asgmFile2.add(new File("./AsgmFiles/Module2--Requirements.ppt"));
			double percentWeight2 = 34.0d;
			Date createdDate2 = new Date();
			Date avaiDate2 = new Date(1386326580000l);
			Date dueDate2 = new Date(1386753180000l);
			Date expDate2 = new Date(1387708980000l);
			listOfAssignment.add(new CmsAssignment(asgmID2, asgmTitle2, asgmDescription2, asgmFile2, percentWeight2, createdDate2, avaiDate2, dueDate2, expDate2));
			
			
			//Highlight the Assignment Button
			mainView.displayAssignmentMainStudentPage(StudentAssignmentActivities.getListOfAssignments(user.getUsername(), user.getSelectedCourse().getCourseID()));
		}
	}
}
